// i.d(t, { X: () => CylinderVolume })
import * as THREE from "three"
import PureObservable from "../observer/pure.observer"

export default class CylinderVolume extends PureObservable {
  _basePoint: THREE.Vector3
  _height: number
  _radius: number
  pointCache: THREE.Vector3
  constructor() {
    super()
    this._basePoint = new THREE.Vector3()
    this._height = 1 / 0
    this._radius = 1 / 0
    this.pointCache = new THREE.Vector3()
  }
  get origin() {
    return this._basePoint
  }
  get basePoint() {
    return this._basePoint
  }
  get height() {
    return this._height
  }
  get radius() {
    return this._radius
  }
  updateBasePoint(e) {
    this.basePoint.set(e.x, e.y, e.z)
  }
  updateHeight(e) {
    this._height = e
  }
  updateRadius(e) {
    this._radius = e
  }
  containsPoint(e) {
    this.pointCache.set(e.x, this._basePoint.y, e.z)
    return this._basePoint.distanceToSquared(this.pointCache) <= this.radius ** 2 && this._basePoint.y <= e.y && e.y <= this._basePoint.y + this.height
  }
}
